

import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;


public class SelectionBox extends Rectangle2D.Double {
		
	double startx = 0;
	double starty = 0;
	double endx = 0;
	double endy = 0;
	
	public SelectionBox() {
		super();
		update();
	}
	
	public void setStart(double x, double y) {
		startx = x;
		starty = y;
		update();
	}
	public void setEnd(double x, double y) {
		endx = x;
		endy = y;
		update();
	}
	
	private void update() {
		double x1 = Math.min(startx,endx);
		double x2 = Math.max(startx,endx);
		double y1 = Math.min(starty,endy);
		double y2 = Math.max(starty,endy);
		super.setRect(x1,y1,x2-x1,y2-y1);
	}
}
 

